package com.itheima.springbootquickstart;

import com.itheima.pojo.Country;
import com.itheima.pojo.Province;
import com.itheima.springbootquickstart.config.CommonConfig;
import com.itheima.springbootquickstart.config.CommonImportSelector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.context.annotation.Import;

@Import({CommonConfig.class, CommonImportSelector.class})
@SpringBootApplication
@ComponentScan(basePackageClasses = CommonConfig.class)
@ComponentScans({@ComponentScan("com.itheima")})
public class SpringbootQuickstartApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SpringbootQuickstartApplication.class, args);
        System.out.println(hasBean(Country.class, context));
        System.out.println(hasBean(Province.class, context));
    }

    public static String hasBean(Class<?> clazz, ConfigurableApplicationContext context) {
        String clazzName = clazz.getSimpleName();
        return "%s:%s".formatted(clazzName, context.containsBean(clazzName));
    }

//    @Bean
//    public Country country() {
//        return new Country();
//    }
}
